package com.show.business.device.controller;
import com.show.business.common.core.controller.BaseController;
import com.show.business.device.bean.DeviceGroup;
import com.show.business.device.service.IDeviceGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 设备分组 前端控制器
 * </p>
 *
 * @author dvlp
 * @since 2024-09-30
 */
@Api(value = "设备分组",description = "设备分组")
@RestController
@RequestMapping("/device/deviceGroup")
public class DeviceGroupController extends BaseController {
    @Resource
    private IDeviceGroupService deviceGroupService;
    /**
     * 获取设备分组列表
     */
    @ApiOperation("获取设备分组列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", dataType = "Integer", dataTypeClass = Integer.class)
    })
    @GetMapping("/page")
    public Object getPage(DeviceGroup deviceGroup) {
        startPage();
        List<DeviceGroup> list = deviceGroupService.getList(deviceGroup);
        return getDataTable(list);
    }
    /**
     * 添加设备分组
     */
    @ApiOperation("添加设备分组")
    @PostMapping("/save")
    public Object add(@RequestBody DeviceGroup deviceGroup) {
        return deviceGroupService.saveInfo(deviceGroup);
    }
    /**
     * 更新设备分组
     */
    @ApiOperation("更新设备分组")
    @PostMapping("/edit")
    public Object edit(@RequestBody DeviceGroup deviceGroup) {
        return deviceGroupService.editInfo(deviceGroup);
    }

    /**
     * 启用设备分组
     */
    @ApiOperation("启用设备分组")
    @GetMapping("/enable")
    public Object enable(@RequestParam String id) {
        return deviceGroupService.enable(id);
    }

    /**
     * 禁用设备分组
     */
    @ApiOperation("禁用设备分组")
    @GetMapping("/disable")
    public Object disable(@RequestParam String id) {
        return deviceGroupService.disable(id);
    }
    /**
     * 删除设备分组
     */
    @ApiOperation("删除")
    @ApiImplicitParam(name = "id", value = "主键ID", required = true, dataType = "String", dataTypeClass = String.class)
    @DeleteMapping("/del")
    public Object del(@RequestParam String[] id) {
        return deviceGroupService.delInfos(id);
    }
    /**
     * 设备分组详情
     */
    @ApiOperation("详情")
    @ApiImplicitParam(name = "id", value = "主键ID", required = true, dataType = "String", dataTypeClass = String.class)
    @GetMapping("/info")
    public Object getDeviceGroup(@RequestParam String id) {
        return deviceGroupService.getInfo(id);
    }
}
